package com.imc.api.order.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*
 * 类描述：订单实体类
 * 开发者：tanweiping
 * 创建日期：2018/10/28 21:19
 */
@Entity
@Table(name = "t_order")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Order {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;//主键ID
    private String userId;//用户ID
    @Column(length = 20)
    private String userSubId;//用户ID
    private BigDecimal orderAmount;//订单价格

    @Column(length = 10)
    private Integer orderTakeClassTime;//订单课时
    private String orderDate;//下单时间
    private String transactionId;//流水号

    private String tradeNo;//交易号

    private String tradeType;//交易类型

    private String prepayId;//与支付ID

    /*
    -2，退款失败
    -1，支付失败
    0,订单初始化
    1,未支付
    2,支付成功
    3,支付取消
    4，退款成功
     */
    private int status;


    /*
     * YT  2018/10/28 21:20
     * 方法描述：获取订单状态
     */
    @Transient
    public static String getStatusLabel(String orderStatus) {
        String label = "";
        switch (orderStatus) {
            case "0":
                label = "订单初始化";
                break;
            case "1":
                label = "未支付";
                break;
            case "2":
                label = "支付成功";
                break;
            case "3":
                label = "支付取消";
                break;
            case "4":
                label = "退款成功";
                break;
            case "-1":
                label = "支付失败";
                break;
            case "-2":
                label = "退款失败";
                break;

        }
        return label;
    }

    @Transient
    private List <OrderDetail> orderDetailList;//订单详情列表
}
